#pragma once
#ifndef __HWINLOG_H__
#define __HWINLOG_H__

#include "hwinstring.h"


namespace harlinn
{
    namespace windows
    {
        namespace logging
        {
            class Trace
            {
                Trace* previous;
                const char* function; 
                const char* file; 
                int line;
            public:
                HWIN_EXPORT Trace(const char* theFunction, const char* theFile, int theLine);
                HWIN_EXPORT ~Trace();
            };


            enum class Level : int
            {
                // Shutdown the logger.
                Shutdown = 01,

                // Messages indicating function-calling sequence.
                Trace = 02,

                // Messages that contain information normally of use only when debugging a program.
                Debug = 04,

                // Informational messages.
                Info = 010,

                // Conditions that are not error conditions, but that may require special handling
                Notice = 020,

                // Warning messages.
                Warning = 040,

                // Initialize the logger.
                Startup = 0100,

                // Error messages.
                Error = 0200,

                // Critical conditions, such as hard device errors.
                Critical = 0400,

                // A condition that should be corrected immediately, such as a corrupted system database.
                Alert = 01000,

                // A panic condition. This is normally broadcast to all users
                Emergency = 02000
            };

            class RecordData
            {
                friend class Record;
                INT32 referenceCount; // <-- Not transmitted
                UINT32 size;
                Level level;
                UINT32 processId;
                unsigned long long timestamp;
                UINT32 threadId;
                wchar_t message[128]; // <-- transmitted as UTF8

            };

            class Record
            {
                RecordData* data;

                static const size_t fixed_size = offsetof(RecordData,message);
            public:
                Record()
                    : data(nullptr)
                {}

                Record(Level level, const wchar_t* message, UINT32 messageLength );



            };

        };
    };
};

#ifdef HWIN_ENABLE_TRACE
#define HWIN_TRACE() harlinn::windows::logging::Trace __hwin__trace__(__FUNCTION__,__FILE__,__LINE__)
#else
#define HWIN_TRACE()
#endif


#endif //__HWINLOG_H__
